package com.pdool.game.dict;

import com.pdool.game.cache.AbsConfigCache;
import com.pdool.game.dict.vo.CardVo;
import com.pdool.game.dict.vo.ItemVo;
import org.springframework.stereotype.Component;

import java.util.Map;

@Component
public class CardConfig extends AbsConfigCache<Integer, CardVo> {
    public CardConfig() {
        super("卡牌表_card_info.xlsx",3);
    }

    @Override
    protected CardVo convert2Value(Map<Integer, String> rowData) {
        int id = Integer.parseInt(rowData.get(0));
        String name = rowData.get(1);
        int type = Integer.parseInt(rowData.get(2));
        int cost = Integer.parseInt(rowData.get(3));
        int act = Integer.parseInt(rowData.get(4));
        int lv = Integer.parseInt(rowData.get(5));
        int item = Integer.parseInt(rowData.get(6));
        String levelCost = rowData.get(7);
        int effect = Integer.parseInt(rowData.get(9));
        int effectType = Integer.parseInt(rowData.get(10));
        int limit = Integer.parseInt(rowData.get(11));
        CardVo build = CardVo.builder().id(id)
                .name(name)
                .type(type)
                .cost(cost)
                .act(act)
                .lv(lv)
                .item(item)
                .levelCost(levelCost)
                .effect(effect)
                .effectType(effectType)
                .limit(limit)
                .build();

        return build;
    }

    @Override
    protected Integer convert2Key(Map<Integer, String> rowData) {
        String s = rowData.get(0);
        return Integer.valueOf(s);
    }
}
